//
// Created by Administrator on 2021/9/13.
//
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <climits>

using namespace std;

class Solution {
public:
    int numberOfBoomerangs(vector<vector<int>> &points) {
        int ans = 0;
        int n = (int) points.size();
        for (vector<int> &p: points) {
            // 和这个点距离相同的点构成的hash表
            unordered_map<int, int> um;
            for (vector<int> &q: points) {
                int range = (p[0] - q[0]) * (p[0] - q[0]) + (p[1] - q[1]) * (p[1] - q[1]);
                ++um[range];
            }
            for (auto &kv: um) {
                // 每个距离的集合 可以构成的数量为n*(n-1)
                ans += kv.second * (kv.second - 1);
            }
        }
        return ans;
    }
};

int main() {
    vector<vector<int>> points{{0, 0},
                               {1, 0},
                               {2, 0}};
    Solution solution;
    cout << solution.numberOfBoomerangs(points) << endl;
    return 0;
}
